quicksort([X|Xs],L2):- 
    partition(Xs,X,Littles,Bigs),
    quicksort(Littles,Ls),
    quicksort(Bigs,Bs),
    append(Ls,[X|Bs],L2).
quicksort([],[]).
partition([],_,[],[]):-!.
partition([X|Xs],Y,[X|Z],Bs):-
    X<Y,!,
    partition(Xs,Y,Z,Bs).
partition([X|Xs],Y,Ls,[X|Z]):-
    partition(Xs,Y,Ls,Z).
